<div class="widthauto" id="header">
  <div class="widthauto">
    <div class="pub_wid">
      <ul class="head_top widthauto">
        <li class="lf la"><a href="/">数字化物流招标服务商</a></li>
        <li class="rg ld"><a href="/">客服热线：4006 515156</a></li>
        <li v-if="!status" class="rg lb"><a href="/index/member/index">还没有账号，马上注册</a></li>
        <li v-if="!status" class="rg lc"><a href="/index/member/login">已有账号，马上登陆</a></li>
        <li v-if="status" class="rg le"><a @click="logout()">退出登录</a></li>
        <li v-if="status" class="rg lg"><a @click="changeNav(5)">用户中心</a></li>
        <li v-if="status" class="rg le"><a href="#">{{name}}</a></li>
      </ul>
    </div>
  </div>
  <div class="widthauto bgb">
    <div class="pub_wid head_eye">
      <dl class="lf">
        <a href="/">
          <dt><img src="/static/index/public/images/logo.png" /></dt>
          <dd>专注物流招标服务15年</dd>
        </a>
      </dl>
      <p class="rg"><a :href="advertisingOne.link_url"><img :src="advertisingOne.image_url" /></a></p>
    </div>
  </div>
  <div class="widthauto head_nav">
    <div class="pub_wid">
      <ul class="widthauto">
        <li><a href="/" class="curhome" :class="[navStatus==1?'active':'']" @click="changeNav(1)">首页</a></li>
        <li><a href="/index/tender/index" class="notice" :class="[navStatus==2?'active':'']" @click="changeNav(2)">招标公告</a></li>
        <li><a href="/index/source/index" class="goods" :class="[navStatus==3?'active':'']" @click="changeNav(3)">实时货源</a></li>
        <li><a href="/index/enterprise/index" class="enterprise" :class="[navStatus==4?'active':'']" @click="changeNav(4)">企业库</a></li>
        <li class="member"><a href="/index/content/index/id/2"  class="vip" :class="[navStatus==6?'active':'']" @click="changeNav(6)">会员服务</a></li>
      </ul>
    </div>
  </div>
</div>
<script>
  var vmHeader = new Vue({
    el:'#header',
    data:{
      advertisingOne:{},//广告一
      phone:'',
      status:false,
      name:'',
      navStatus:0
    },
    methods:{
      getMember:function (phone) {
        var el = this;
        var postData = {
          'phone':phone,
        }
        AjaxPost(postData,'/index/member/getMemberByPhone').then((response)=>{
          if(response.result !=null){
            el.status = true;
            el.name =response.result.nickname  || response.result.phone
          }else {
            el.status = false
          }

        })
      },
      changeNav:function(num){
        var el = this
        sessionStorage.setItem("navStatus",num);
        if(num == 5){
          if(localStorage.getItem('memberId')){
            if(localStorage.getItem('member_status') ){
              if(localStorage.getItem('member_status') == 0){
                window.location.href='/index/member/auditLoading'
              }else{
                if(localStorage.getItem('member_category')){
                  if(localStorage.getItem('member_category')==1){
                    window.location.href='/index/consignor/index'
                  }else if(localStorage.getItem('member_category')==2){
                    window.location.href='/index/logistics/index'
                  }else {
                    window.location.href='/index/member/loginSuccess'
                  }
                }else {
                  window.location.href='/index/member/loginSuccess'
                }
              }

            }else{
              window.location.href='/index/member/loginSuccess'
            }

          }else{
            window.location.href='/index/member/login'
          }

        }else {
          el.navStatus = num
        }

      },
      logout:function () {
        AjaxPostFree('/index/member/memberLogout').then((response)=>{
          console.log(response)
          // localStorage.removeItem("memberPhone");
          // localStorage.removeItem("memberId")
          // localStorage.removeItem("member_category")
          // localStorage.removeItem("member_grade")
          // localStorage.removeItem("member_status");
          localStorage.clear()
          window.location.href='/index/member/login'
        })
      },
      //获取首页显示的物流企业
      getAdvertisingOne:function () {
        var el = this
        var postData = {
          'id':1,
        }
        AjaxPost(postData,'/index/index/getAdvertisingLimitList').then((response)=>{
          if(response.status==1){
            if(response.result){
              el.advertisingOne = response.result
            }
          }
          console.log(el.advertisingOne)
        })
      }
    },
    mounted(){
      this.getAdvertisingOne()
      if(localStorage.getItem("memberPhone") != null){
        this.getMember(localStorage.getItem("memberPhone"))
      }
      this.$nextTick(function () {
        if(sessionStorage.getItem("navStatus")){
          this.navStatus = sessionStorage.getItem("navStatus")
        }
      })

    }
  })
</script>
